package de.tum.in.eist.poll.server;

import java.util.List;

import de.tum.in.eist.poll.server.PollService;
import de.tum.in.eist.poll.shared.beans.Lecture;
import de.tum.in.eist.poll.shared.beans.Feedback;
import de.tum.in.eist.poll.shared.beans.User;
import de.tum.in.eist.poll.shared.dao.FeedbackDaoImpl;
import de.tum.in.eist.poll.shared.dao.FeedbackDaoInterface;
import de.tum.in.eist.poll.shared.dao.UserDaoImpl;
import de.tum.in.eist.poll.shared.dao.UserDaoInterface;

public class PollServiceImpl implements PollService {
	private FeedbackDaoInterface feedbackStore
		= new FeedbackDaoImpl();
	private UserDaoInterface userStore
		= new UserDaoImpl();

	@Override
	public User login(String name, String password)
			throws IllegalArgumentException {
		User user = userStore.get(name);
		if (user == null || user.getPassword() != password)
			throw new IllegalArgumentException();
		return user;
	}

	@Override
	public List<Lecture> requestLectures(User user) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Feedback> requestFeedback(Lecture lecture) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String submitFeedback(Feedback feedback) {
		feedbackStore.add(feedback);
		// TODO: answer something
		return "Feedback has been comitted";
	}

}
